/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jjsoft.sistemafacturacion.gco.mdl;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.hibernate.search.annotations.Analyze;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

/**
 *
 * @author Johnny
 */
@Entity
@Indexed
@Table(catalog = "facturacion", schema = "", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"codigo"})})
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Articulo.findAll", query = "SELECT a FROM Articulo a"),
    @NamedQuery(name = "Articulo.findByIdarticulo", query = "SELECT a FROM Articulo a WHERE a.idarticulo = :idarticulo"),
    @NamedQuery(name = "Articulo.findByCodigo", query = "SELECT a FROM Articulo a WHERE a.codigo = :codigo"),
    @NamedQuery(name = "Articulo.findByDescripcion", query = "SELECT a FROM Articulo a WHERE a.descripcion = :descripcion"),
    @NamedQuery(name = "Articulo.findByPCosto", query = "SELECT a FROM Articulo a WHERE a.pCosto = :pCosto"),
    @NamedQuery(name = "Articulo.findByPVenta", query = "SELECT a FROM Articulo a WHERE a.pVenta = :pVenta"),
    @NamedQuery(name = "Articulo.findByIva", query = "SELECT a FROM Articulo a WHERE a.iva = :iva"),
    @NamedQuery(name = "Articulo.findByStock", query = "SELECT a FROM Articulo a WHERE a.stock = :stock"),
    @NamedQuery(name = "Articulo.findBySminimo", query = "SELECT a FROM Articulo a WHERE a.sminimo = :sminimo"),
    @NamedQuery(name = "Articulo.findByMarca", query = "SELECT a FROM Articulo a WHERE a.marca = :marca"),
    @NamedQuery(name = "Articulo.findByModelo", query = "SELECT a FROM Articulo a WHERE a.modelo = :modelo"),
    @NamedQuery(name = "Articulo.findByEstado", query = "SELECT a FROM Articulo a WHERE a.estado = :estado")})
public class Articulo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(nullable = false)
    private Integer idarticulo;
    @Basic(optional = false)
    @Column(nullable = false, length = 45)
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
    private String codigo;
    @Column(length = 45)
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
    private String descripcion;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(precision = 22)
    private Double pCosto;
    @Column(precision = 22)
    private Double pVenta;
    @Column(length = 45)
    private String iva;
    @Column(length = 45)
    private Integer stock;
    @Column(length = 45)
    private Integer sminimo;
    @Column(length = 45)
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
    private String marca;
    @Column(length = 45)
    @Field(index=Index.YES, analyze=Analyze.YES, store=Store.YES)
    private String modelo;
    private Integer estado;
    @OneToMany(mappedBy = "idArticulo")
    private List<Detallefactura> detallefacturaList;
    @OneToMany(mappedBy = "idArticulo")
    private List<Proveedorarticulo> proveedorarticuloList;

    public Articulo() {
    }

    public Articulo(Integer idarticulo) {
        this.idarticulo = idarticulo;
    }

    public Articulo(Integer idarticulo, String codigo) {
        this.idarticulo = idarticulo;
        this.codigo = codigo;
    }

    public Integer getIdarticulo() {
        return idarticulo;
    }

    public void setIdarticulo(Integer idarticulo) {
        this.idarticulo = idarticulo;
    }

    public String getCodigo() {
        return codigo;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Double getPCosto() {
        return pCosto;
    }

    public void setPCosto(Double pCosto) {
        this.pCosto = pCosto;
    }

    public Double getPVenta() {
        return pVenta;
    }

    public void setPVenta(Double pVenta) {
        this.pVenta = pVenta;
    }

    public String getIva() {
        return iva;
    }

    public void setIva(String iva) {
        this.iva = iva;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public Integer getSminimo() {
        return sminimo;
    }

    public void setSminimo(Integer sminimo) {
        this.sminimo = sminimo;
    }

    public String getMarca() {
        return marca;
    }

    public void setMarca(String marca) {
        this.marca = marca;
    }

    public String getModelo() {
        return modelo;
    }

    public void setModelo(String modelo) {
        this.modelo = modelo;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    @XmlTransient
    @JsonIgnore
    public List<Detallefactura> getDetallefacturaList() {
        return detallefacturaList;
    }

    public void setDetallefacturaList(List<Detallefactura> detallefacturaList) {
        this.detallefacturaList = detallefacturaList;
    }

    @XmlTransient
    @JsonIgnore
    public List<Proveedorarticulo> getProveedorarticuloList() {
        return proveedorarticuloList;
    }

    public void setProveedorarticuloList(List<Proveedorarticulo> proveedorarticuloList) {
        this.proveedorarticuloList = proveedorarticuloList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idarticulo != null ? idarticulo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Articulo)) {
            return false;
        }
        Articulo other = (Articulo) object;
        if ((this.idarticulo == null && other.idarticulo != null) || (this.idarticulo != null && !this.idarticulo.equals(other.idarticulo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.jjsoft.sistemafacturacion.gco.mdl.Articulo[ idarticulo=" + idarticulo + " ]";
    }
    
}
